import pathlib
import sys
import inspect


_toolname = ''

def get_caller_file_path():
    frame = inspect.currentframe().f_back.f_back
    caller_file_path = frame.f_code.co_filename
    return pathlib.Path(caller_file_path).absolute().parts[-1]


def getToolName():
    global _toolname
    _toolnameRaw = get_caller_file_path()
    _toolname = _toolnameRaw[2:-5]
    return _toolname


def getToolNameByImport(filePath):
    tollName = pathlib.Path(filePath).absolute().parts[-1]
    _toolname = tollName[2:-5]
    return _toolname


def getToolArgv():
    if (_toolname == ''):
        getToolName()
    _thisArgInd = sys.argv.index(_toolname)
    return sys.argv[_thisArgInd + 1:]
